<template>
  <div id="app">
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        <span>{{ item }}</span>
        <button @click="delBtn(index)">删除</button>
      </li>
    </ul>
    <button @click="addBtn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [5, 7, 1],
    }
  },
  methods: {
    addBtn() {
      // Math.floor(Math.random() * 10)
      let random = Math.floor(Math.random() * 10)
      this.arr.push(random)
    },
    delBtn(index) {
      this.arr.splice(index, 1)
    },
  },
}
</script>

<style></style>
